package liurong.driver.javassist;

import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtMethod;
import javassist.CtNewMethod;

public class JavassistTest {
	public static void main(String[] args) throws Exception {
		ClassPool classPool = ClassPool.getDefault();
		
		CtClass ctClass = classPool.makeClass("liurong.driver.javassist.CreateClass");
		
		CtMethod ctMethod = CtNewMethod.make("public void test(){}", ctClass);
		
		ctMethod.insertBefore("System.out.println(1234);");
		
		ctClass.addMethod(ctMethod);
		
		ctClass.writeFile("d://temp");
	}
}
